﻿@{
    ViewBag.zhanghuguanli = "active";
    ViewBag.Title = "添加酒店子账号";
    Layout = "~/Views/Shared/_layout_jiudian.cshtml";
}



<div class="">
    <div class="title_name">@ViewBag.sub_title</div>
    <div class="newuser_name">
        <span>姓名</span>
        <input type="text" placeholder="请输入姓名" class="input_sy" v-model="modelyh.xingming">
    </div>
    <div class="newuser_name">
        <span>登录号码</span>
        <input id="user-name" type="text" placeholder="请输入手机号" class="input_sy" v-model="modelyh.zhanghao">
    </div>
    <div class="newuser_name">
        <span>验证码</span>
        <input id="dxyzm" type="text" placeholder="请输入手机验证码" class="input_sy" value="" />
        <i id="divsendduanxin" onclick="sendduanxin();" style="cursor: pointer; color: #28A5E1">发送手机验证码</i>
    </div>
    <div class="newuser_name">
        <span>酒店名称</span>
        <label style="width:auto !important;" v-for="(jd,index) in modelyh.lisjd">
            <input type="checkbox" name="ckquanxian" :value="jd.id" v-model="modelyh.lisjdid" />{{jd.jd_name}}
        </label>
    </div>
    <div class="kong20"></div>

    <div class="newuser_name" style="padding-left:150px;">
        <button class="btn btn-primary" v-on:click="JDYHShowP();">保存提交</button>
        <i id="lb_errmg" class="ft-red" style="display:none;">登录失败</i>
    </div>
</div>


<script>
    var vm = new Vue({
        el: '#app',
        data: {
            modelyh:@Html.Raw(ViewBag.modelyh),

        },
        methods: {

            JDYHShowP: function () {
                $.post("/JiuDian/JDYHShowP", { modelyh: JSON.stringify(vm.modelyh), dxyzm: $("#dxyzm").val() }, function (res) {
                    if (res.code > 0) {
                        location.href = "/JiuDian/JDZhangHu";
                    }
                    else {
                        showerr(true, res.msg);
                    }
                })
            },

        }
    })

    $(function () {

    });
    function showerr(show, msg) {
        if (show) {
            $("#lb_errmg").html(msg);
            $("#lb_errmg").show();
        }
        else {
            $("#lb_errmg").hide();
        }
    }
    function sendduanxin() {
        $.post("/login/sendduanxin", { name: $("#user-name").val(), imgyzm: "0000" }, function (res) {
            showerr(true, res.msg);
            if (res.code > 0) {
                var secondleft = 59;
                intervalindex = setInterval(function () {
                    if (secondleft > 0) {
                        secondleft--;
                        $("#divsendduanxin").html("重试(" + secondleft + ")");
                    }
                    else {
                        clearInterval(intervalindex);
                        $("#divsendduanxin").html("发送手机验证码");
                    }
                }, 1000)

            }
        })
    }
</script>